from django.db import models
from django.contrib.auth.models import AbstractUser
from datetime import datetime


# Create your models here.
class Group(models.Model):
    name = models.CharField(max_length=200)
    number = models.IntegerField(default=-1)
    is_delete = models.BooleanField(default=False)
    CreatedAt = models.DateTimeField(max_length=200, auto_now_add=True)
    UpdatedAt = models.DateTimeField(max_length=200, auto_now=True)
    StartedAt = models.DateTimeField(max_length=200, default=datetime.now)
    EndAt = models.DateTimeField(max_length=200, default=datetime.now)

    class Meta:
        verbose_name = u'班级'
        verbose_name_plural = u'班级'

    def __str__(self):
        return self.name


class MyUser(AbstractUser):
    nickname = models.CharField(default='test', max_length=200)
    # 实际班级号
    nickclassnumber = models.IntegerField(default=-1)
    group = models.ForeignKey(Group, related_name='user_group', on_delete=models.CASCADE, default=1)

    def __str__(self):
        return self.username

    class Meta:
        verbose_name = u'账号'
        verbose_name_plural = u'账号'
